{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7794a6b4",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import netCDF4 as nc\n",
    "import numpy as np\n",
    "from osgeo import gdal,osr,ogr\n",
    "import glob"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "952e3ae4",
   "metadata": {},
   "outputs": [],
   "source": [
    "nf = nc.Dataset(r\"D:\\XiaLei_data\\original_data\\GFAS\\2014\\2014-1.nc\",'r')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "ed83d493",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dict_keys(['valid_time', 'latitude', 'longitude', 'co2fire'])"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nf.variables.keys()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "6f7fdff4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<class 'netCDF4._netCDF4.Variable'>\n",
       "int64 valid_time(valid_time)\n",
       "    long_name: time\n",
       "    standard_name: time\n",
       "    units: seconds since 1970-01-01\n",
       "    calendar: proleptic_gregorian\n",
       "unlimited dimensions: \n",
       "current shape = (31,)\n",
       "filling on, default _FillValue of -9223372036854775806 used"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#查看一下time的属性\n",
    "nf.variables['valid_time']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b30e39d6",
   "metadata": {},
   "outputs": [],
   "source": [
    "#FINN\n",
    "def nc2tif(data,Output_folder):\n",
    "    tmp_data = nc.Dataset(data)   #利用.Dataset()方法读取nc数据\n",
    "    # print(tmp_data)\n",
    "    # <class 'netCDF4._netCDF4.Dataset'>\n",
    "    # root group (NETCDF3_CLASSIC data model, file format NETCDF3):\n",
    "    # dimensions(sizes): lon(7849), lat(5146), time(12)\n",
    "    # variables(dimensions): float64 lon(lon), float64 lat(lat), float64 time(time), int16 tmp(time, lat, lon)\n",
    "    # print(tmp_data.variables)   #lon, lat, time, tmp\n",
    "    # {'lon': <class 'netCDF4._netCDF4.Variable'>\n",
    "    # float64 lon(lon)\n",
    "    # long_name: longitude\n",
    "    # unit: degree\n",
    "    # unlimited dimensions: \n",
    "    # current shape = (7849,)\n",
    "    # filling on, default _FillValue of 9.969209968386869e+36 used, 'lat': <class 'netCDF4._netCDF4.Variable'>\n",
    "    # float64 lat(lat)\n",
    "    # long_name: latitude\n",
    "    # unit: degree\n",
    "    # unlimited dimensions: \n",
    "    # current shape = (5146,)\n",
    "    # filling on, default _FillValue of 9.969209968386869e+36 used, 'time': <class 'netCDF4._netCDF4.Variable'>\n",
    "    # float64 time(time)\n",
    "    # long_name: time\n",
    "    # unit: data.01-data.12\n",
    "    # calendar: gregorian\n",
    "    # unlimited dimensions: \n",
    "    # current shape = (12,)\n",
    "    # filling on, default _FillValue of 9.969209968386869e+36 used, 'tmp': <class 'netCDF4._netCDF4.Variable'>\n",
    "    # int16 tmp(time, lat, lon)\n",
    "    # long_name: 0.1 monthly mean temperature\n",
    "    # unit: degree centigrade\n",
    "    # missing_value: -32768.0\n",
    "    # unlimited dimensions: \n",
    "    # current shape = (12, 5146, 7849)\n",
    "    # filling on, default _FillValue of -32767 used}\n",
    "\n",
    "    Lat_data = tmp_data.variables['lat'][:]\n",
    "    Lon_data = tmp_data.variables['lon'][:]\n",
    "    # print(Lat_data)\n",
    "    # [58.63129069 58.62295736 58.61462403 ... 15.77295736 15.76462403\n",
    "    #  15.75629069]\n",
    "    # print(Lon_data)\n",
    "    # [ 71.29005534  71.29838867  71.30672201 ... 136.67338867 136.68172201\n",
    "    #  136.69005534]\n",
    "    \n",
    "    tmp_arr = np.asarray(tmp_data.variables['fire_modis_CO2'])\n",
    "    \n",
    "    #影像的左上角&右下角坐标\n",
    "    Lonmin, Latmax, Lonmax, Latmin = [Lon_data.min(), Lat_data.max(), Lon_data.max(), Lat_data.min()]\n",
    "    # Lonmin, Latmax, Lonmax, Latmin\n",
    "    # (71.29005533854166, 58.63129069182766, 136.6900553385789, 15.756290691830095)\n",
    "    \n",
    "    #分辨率计算\n",
    "    Num_lat = len(Lat_data)    #5146\n",
    "    Num_lon = len(Lon_data)  #7849\n",
    "    Lat_res = (Latmax - Latmin) / (float(Num_lat) - 1)\n",
    "    Lon_res = (Lonmax - Lonmin) / (float(Num_lon) - 1)\n",
    "    #print(Num_lat, Num_lon)\n",
    "    #print(Lat_res, Lon_res)\n",
    "    # 5146 7849\n",
    "    # 0.00833333333333286 0.008333333333338078\n",
    "    \n",
    "    for i in range(len(tmp_arr[:])):\n",
    "        #i=0,1,2,3,4,5,6,7,8,9,...\n",
    "    #创建tif文件\n",
    "        driver=gdal.GetDriverByName('GTiff')\n",
    "        out_tif_name = Output_folder +'\\\\'+ data.split('\\\\')[-1].split('.')[0] + '_' + str(i+1) + '.tif'\n",
    "        out_tif = driver.Create(out_tif_name, Num_lon, Num_lat, 1, gdal.GDT_Float32)\n",
    "        \n",
    "        #设置影像的显示范围\n",
    "            #Lat_re前需要添加负号\n",
    "        geotransform = (Lonmin, Lon_res, 0.0, Latmax, 0.0, -Lat_res)\n",
    "        out_tif.SetGeoTransform(geotransform)\n",
    "                \n",
    "        #定义投影\n",
    "        prj = osr.SpatialReference()\n",
    "        prj.ImportFromEPSG(4326)\n",
    "        out_tif.SetProjection(prj.ExportToWkt())\n",
    "    \n",
    "        #数据导出\n",
    "        out_tif.GetRasterBand(1).WriteArray(np.flipud(tmp_arr[i]))  #将数据写入内存，此时没有写入到硬盘\n",
    "        out_tif.FlushCache()   #将数据写入到硬盘\n",
    "        out_tif = None #关闭tif文件 \n",
    "\n",
    "def main():\n",
    "    Input_folder = 'D:\\XiaLei_data\\original_data\\FINN\\MODIS'\n",
    "    Output_folder = r'D:\\XiaLei_data\\output_data\\tif\\FINN\\MODIS\\2013_xia'\n",
    "    Input_NCfile=\"D:\\XiaLei_data\\original_data\\FINN\\MODIS\\emissions-finnv2.5mod_CO2_bb_surface_daily_20130101-20131231_0.1x0.1.nc\"\n",
    "    \n",
    "    #读取所有数据\n",
    "    # data_list = glob.glob(Input_folder+'\\*.nc')\n",
    "    \n",
    "    # for i in range(len(data_list)):\n",
    "    #     data = data_list[i]\n",
    "    #     nc2tif(data, Output_folder)\n",
    "    #     print(data+'转tif成功')\n",
    "    data=Input_NCfile\n",
    "    nc2tif(data,Output_folder)\n",
    "    print(data+'转tif成功')\n",
    "    \n",
    "        \n",
    "main()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ecbff552",
   "metadata": {},
   "source": [
    "FINN按月分类输出TIFF文件，sdrchxu改写"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "a0ccfa03",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "D:\\XiaLei_data\\original_data\\FINN\\VIIRS\\emissions-finnv2.5modvrs_CO2_bb_surface_daily_20220101-20221231_0.1x0.1.nc 转 tif 成功\n"
     ]
    }
   ],
   "source": [
    "import os\n",
    "import netCDF4 as nc\n",
    "import numpy as np\n",
    "from osgeo import gdal, osr\n",
    "\n",
    "def nc2tif(data, Output_folder):\n",
    "    # 读取 nc 文件\n",
    "    tmp_data = nc.Dataset(data)\n",
    "    Lat_data = tmp_data.variables['lat'][:]\n",
    "    Lon_data = tmp_data.variables['lon'][:]\n",
    "    tmp_arr = np.asarray(tmp_data.variables['fire_modisviirs_CO2'])\n",
    "\n",
    "    # 获取时间信息，计算每一天的月份\n",
    "    time_data = tmp_data.variables['time'][:]\n",
    "    time_units = tmp_data.variables['time'].units\n",
    "    time_calendar = tmp_data.variables['time'].calendar\n",
    "    time_dates = nc.num2date(time_data, units=time_units, calendar=time_calendar)\n",
    "    months = [date.month for date in time_dates]\n",
    "\n",
    "    # 影像的左上角和右下角坐标\n",
    "    Lonmin, Latmax, Lonmax, Latmin = [Lon_data.min(), Lat_data.max(), Lon_data.max(), Lat_data.min()]\n",
    "\n",
    "    # 分辨率计算\n",
    "    Num_lat = len(Lat_data)\n",
    "    Num_lon = len(Lon_data)\n",
    "    Lat_res = (Latmax - Latmin) / (float(Num_lat) - 1)\n",
    "    Lon_res = (Lonmax - Lonmin) / (float(Num_lon) - 1)\n",
    "\n",
    "    for i in range(len(tmp_arr[:])):\n",
    "        # 确定当前文件属于哪个月份\n",
    "        current_month = months[i]\n",
    "\n",
    "        # 创建对应月份的子文件夹\n",
    "        month_folder = os.path.join(Output_folder, f'{current_month:02d}')\n",
    "        if not os.path.exists(month_folder):\n",
    "            os.makedirs(month_folder)\n",
    "\n",
    "        # 创建 TIFF 文件\n",
    "        driver = gdal.GetDriverByName('GTiff')\n",
    "        out_tif_name = os.path.join(month_folder, f'{data.split(os.sep)[-1].split(\".\")[0]}_{i + 1}.tif')\n",
    "        out_tif = driver.Create(out_tif_name, Num_lon, Num_lat, 1, gdal.GDT_Float32)\n",
    "\n",
    "        # 设置影像的显示范围\n",
    "        geotransform = (Lonmin, Lon_res, 0.0, Latmax, 0.0, -Lat_res)\n",
    "        out_tif.SetGeoTransform(geotransform)\n",
    "\n",
    "        # 定义投影\n",
    "        prj = osr.SpatialReference()\n",
    "        prj.ImportFromEPSG(4326)\n",
    "        out_tif.SetProjection(prj.ExportToWkt())\n",
    "\n",
    "        # 数据导出\n",
    "        out_tif.GetRasterBand(1).WriteArray(np.flipud(tmp_arr[i]))  # 将数据写入内存，此时没有写入到硬盘\n",
    "        out_tif.FlushCache()  # 将数据写入到硬盘\n",
    "        out_tif = None  # 关闭 tif 文件\n",
    "\n",
    "def main():\n",
    "    Input_folder = r'D:\\XiaLei_data\\original_data\\FINN\\MODIS'\n",
    "    Output_folder = r\"D:\\XiaLei_data\\output_data\\tif\\FINN\\VIIRS\\2022\"\n",
    "    Input_NCfile = r\"D:\\XiaLei_data\\original_data\\FINN\\VIIRS\\emissions-finnv2.5modvrs_CO2_bb_surface_daily_20220101-20221231_0.1x0.1.nc\"\n",
    "\n",
    "    # 如果主输出文件夹不存在，则创建\n",
    "    if not os.path.exists(Output_folder):\n",
    "        os.makedirs(Output_folder)\n",
    "\n",
    "    # 处理数据\n",
    "    data = Input_NCfile\n",
    "    nc2tif(data, Output_folder)\n",
    "    print(data + ' 转 tif 成功')\n",
    "\n",
    "main()\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5c4fc7de",
   "metadata": {},
   "source": [
    "GFED/GFAS按月分类输出TIFF文件，sdrchxu改写"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "bb2c9da1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "D:\\XiaLei_data\\original_data\\GFED\\GFED5_Beta_monthly_2022.nc 转 tif 成功\n"
     ]
    }
   ],
   "source": [
    "import os\n",
    "import netCDF4 as nc\n",
    "import numpy as np\n",
    "from osgeo import gdal, osr\n",
    "\n",
    "def nc2tif(data, Output_folder):\n",
    "    # 读取 nc 文件\n",
    "    tmp_data = nc.Dataset(data)\n",
    "    Lat_data = tmp_data.variables['lat'][:]\n",
    "    Lon_data = tmp_data.variables['lon'][:]\n",
    "    tmp_arr = np.asarray(tmp_data.variables['CO2'])\n",
    "\n",
    "    # 获取时间信息，计算每一天的月份\n",
    "    time_data = tmp_data.variables['time'][:]\n",
    "    time_units = tmp_data.variables['time'].units\n",
    "    # time_calendar = tmp_data.variables['time'].calendar\n",
    "    time_calendar=\"proleptic_gregorian\"  #GFED的time对象无calendar属性，手动定义\n",
    "    time_dates = nc.num2date(time_data, units=time_units, calendar=time_calendar)\n",
    "    months = [date.month for date in time_dates]\n",
    "\n",
    "    # 影像的左上角和右下角坐标\n",
    "    Lonmin, Latmax, Lonmax, Latmin = [Lon_data.min(), Lat_data.max(), Lon_data.max(), Lat_data.min()]\n",
    "\n",
    "    # 分辨率计算\n",
    "    Num_lat = len(Lat_data)\n",
    "    Num_lon = len(Lon_data)\n",
    "    Lat_res = (Latmax - Latmin) / (float(Num_lat) - 1)\n",
    "    Lon_res = (Lonmax - Lonmin) / (float(Num_lon) - 1)\n",
    "\n",
    "    for i in range(len(tmp_arr[:])):\n",
    "        # 确定当前文件属于哪个月份\n",
    "        current_month = months[i]\n",
    "\n",
    "        # 创建对应月份的子文件夹\n",
    "        month_folder = os.path.join(Output_folder, f'{current_month:02d}')\n",
    "        if not os.path.exists(month_folder):\n",
    "            os.makedirs(month_folder)\n",
    "\n",
    "        # 创建 TIFF 文件\n",
    "        driver = gdal.GetDriverByName('GTiff')\n",
    "        out_tif_name = os.path.join(month_folder, f'{data.split(os.sep)[-1].split(\".\")[0]}_{i + 1}.tif')\n",
    "        out_tif = driver.Create(out_tif_name, Num_lon, Num_lat, 1, gdal.GDT_Float32)\n",
    "\n",
    "        # 设置影像的显示范围\n",
    "        geotransform = (Lonmin, Lon_res, 0.0, Latmax, 0.0, -Lat_res)\n",
    "        out_tif.SetGeoTransform(geotransform)\n",
    "\n",
    "        # 定义投影\n",
    "        prj = osr.SpatialReference()\n",
    "        prj.ImportFromEPSG(4326)\n",
    "        out_tif.SetProjection(prj.ExportToWkt())\n",
    "\n",
    "        # 数据导出\n",
    "        out_tif.GetRasterBand(1).WriteArray(tmp_arr[i])  # 将数据写入内存，此时没有写入到硬盘\n",
    "        out_tif.FlushCache()  # 将数据写入到硬盘\n",
    "        out_tif = None  # 关闭 tif 文件\n",
    "\n",
    "def main():\n",
    "    Input_folder = r\"D:\\XiaLei_data\\original_data\\GFAS\\2022\"\n",
    "    Output_folder = r\"D:\\XiaLei_data\\output_data\\tif\\GFED\\2022\"\n",
    "    Input_NCfile = r\"D:\\XiaLei_data\\original_data\\GFED\\GFED5_Beta_monthly_2022.nc\"\n",
    "\n",
    "    # 如果主输出文件夹不存在，则创建\n",
    "    if not os.path.exists(Output_folder):\n",
    "        os.makedirs(Output_folder)\n",
    "\n",
    "    # # 对于GFED,处理数据\n",
    "    data = Input_NCfile\n",
    "    nc2tif(data, Output_folder)\n",
    "    print(data + ' 转 tif 成功')\n",
    "\n",
    "    # 对于GFAS    \n",
    "    # for data in os.listdir(Input_folder):\n",
    "    #     if data.endswith(\".nc\"):\n",
    "    #         nc2tif(Input_folder+\"\\\\\"+data, Output_folder)\n",
    "    #         print(data+'转tif成功')\n",
    "\n",
    "main()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "224b5687",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "D:\\XiaLei_data\\original_data\\GFAS\\GFAS2013\\GFAS201301.nc转tif成功\n",
      "D:\\XiaLei_data\\original_data\\GFAS\\GFAS2013\\GFAS201302.nc转tif成功\n",
      "D:\\XiaLei_data\\original_data\\GFAS\\GFAS2013\\GFAS201303.nc转tif成功\n",
      "D:\\XiaLei_data\\original_data\\GFAS\\GFAS2013\\GFAS201304.nc转tif成功\n",
      "D:\\XiaLei_data\\original_data\\GFAS\\GFAS2013\\GFAS201305.nc转tif成功\n",
      "D:\\XiaLei_data\\original_data\\GFAS\\GFAS2013\\GFAS201306.nc转tif成功\n",
      "D:\\XiaLei_data\\original_data\\GFAS\\GFAS2013\\GFAS201307.nc转tif成功\n",
      "D:\\XiaLei_data\\original_data\\GFAS\\GFAS2013\\GFAS201308.nc转tif成功\n",
      "D:\\XiaLei_data\\original_data\\GFAS\\GFAS2013\\GFAS201309.nc转tif成功\n",
      "D:\\XiaLei_data\\original_data\\GFAS\\GFAS2013\\GFAS201310.nc转tif成功\n",
      "D:\\XiaLei_data\\original_data\\GFAS\\GFAS2013\\GFAS201311.nc转tif成功\n",
      "D:\\XiaLei_data\\original_data\\GFAS\\GFAS2013\\GFAS201312.nc转tif成功\n"
     ]
    }
   ],
   "source": [
    "#GFED、GFAS\n",
    "def nc2tif(data,Output_folder):\n",
    "    tmp_data = nc.Dataset(data)   #利用.Dataset()方法读取nc数据\n",
    "    # print(tmp_data)\n",
    "    # <class 'netCDF4._netCDF4.Dataset'>\n",
    "    # root group (NETCDF3_CLASSIC data model, file format NETCDF3):\n",
    "    # dimensions(sizes): lon(7849), lat(5146), time(12)\n",
    "    # variables(dimensions): float64 lon(lon), float64 lat(lat), float64 time(time), int16 tmp(time, lat, lon)\n",
    "    # print(tmp_data.variables)   #lon, lat, time, tmp\n",
    "    # {'lon': <class 'netCDF4._netCDF4.Variable'>\n",
    "    # float64 lon(lon)\n",
    "    # long_name: longitude\n",
    "    # unit: degree\n",
    "    # unlimited dimensions: \n",
    "    # current shape = (7849,)\n",
    "    # filling on, default _FillValue of 9.969209968386869e+36 used, 'lat': <class 'netCDF4._netCDF4.Variable'>\n",
    "    # float64 lat(lat)\n",
    "    # long_name: latitude\n",
    "    # unit: degree\n",
    "    # unlimited dimensions: \n",
    "    # current shape = (5146,)\n",
    "    # filling on, default _FillValue of 9.969209968386869e+36 used, 'time': <class 'netCDF4._netCDF4.Variable'>\n",
    "    # float64 time(time)\n",
    "    # long_name: time\n",
    "    # unit: data.01-data.12\n",
    "    # calendar: gregorian\n",
    "    # unlimited dimensions: \n",
    "    # current shape = (12,)\n",
    "    # filling on, default _FillValue of 9.969209968386869e+36 used, 'tmp': <class 'netCDF4._netCDF4.Variable'>\n",
    "    # int16 tmp(time, lat, lon)\n",
    "    # long_name: 0.1 monthly mean temperature\n",
    "    # unit: degree centigrade\n",
    "    # missing_value: -32768.0\n",
    "    # unlimited dimensions: \n",
    "    # current shape = (12, 5146, 7849)\n",
    "    # filling on, default _FillValue of -32767 used}\n",
    "\n",
    "    Lat_data = tmp_data.variables['latitude'][:]\n",
    "    Lon_data = tmp_data.variables['longitude'][:]\n",
    "    # print(Lat_data)\n",
    "    # [58.63129069 58.62295736 58.61462403 ... 15.77295736 15.76462403\n",
    "    #  15.75629069]\n",
    "    # print(Lon_data)\n",
    "    # [ 71.29005534  71.29838867  71.30672201 ... 136.67338867 136.68172201\n",
    "    #  136.69005534]\n",
    "    \n",
    "    tmp_arr = np.asarray(tmp_data.variables['co2fire'])\n",
    "    \n",
    "    #影像的左上角&右下角坐标\n",
    "    Lonmin, Latmax, Lonmax, Latmin = [Lon_data.min(), Lat_data.max(), Lon_data.max(), Lat_data.min()]\n",
    "    # Lonmin, Latmax, Lonmax, Latmin\n",
    "    # (71.29005533854166, 58.63129069182766, 136.6900553385789, 15.756290691830095)\n",
    "    \n",
    "    #分辨率计算\n",
    "    Num_lat = len(Lat_data)    #5146\n",
    "    Num_lon = len(Lon_data)  #7849\n",
    "    Lat_res = (Latmax - Latmin) / (float(Num_lat) - 1)\n",
    "    Lon_res = (Lonmax - Lonmin) / (float(Num_lon) - 1)\n",
    "    #print(Num_lat, Num_lon)\n",
    "    #print(Lat_res, Lon_res)\n",
    "    # 5146 7849\n",
    "    # 0.00833333333333286 0.008333333333338078\n",
    "    \n",
    "    for i in range(len(tmp_arr[:])):\n",
    "        #i=0,1,2,3,4,5,6,7,8,9,...\n",
    "    #创建tif文件\n",
    "        driver=gdal.GetDriverByName('GTiff')\n",
    "        out_tif_name = Output_folder +'\\\\'+ data.split('\\\\')[-1].split('.')[0] + '_' + str(i+1) + '.tif'\n",
    "        out_tif = driver.Create(out_tif_name, Num_lon, Num_lat, 1, gdal.GDT_Float32)\n",
    "        \n",
    "        #设置影像的显示范围\n",
    "            #Lat_re前需要添加负号\n",
    "        geotransform = (Lonmin, Lon_res, 0.0, Latmax, 0.0, -Lat_res)\n",
    "        out_tif.SetGeoTransform(geotransform)\n",
    "                \n",
    "        #定义投影\n",
    "        prj = osr.SpatialReference()\n",
    "        prj.ImportFromEPSG(4326)\n",
    "        out_tif.SetProjection(prj.ExportToWkt())\n",
    "    \n",
    "        #数据导出\n",
    "        out_tif.GetRasterBand(1).WriteArray(tmp_arr[i])  #将数据写入内存，此时没有写入到硬盘\n",
    "        out_tif.FlushCache()   #将数据写入到硬盘\n",
    "        out_tif = None #关闭tif文件 \n",
    "\n",
    "def main():\n",
    "    Input_folder = 'D:\\XiaLei_data\\original_data\\GFAS\\GFAS2013'\n",
    "    Output_folder = r\"D:\\XiaLei_data\\output_data\\tif\\GFAS\\2013_xia\"\n",
    "    #读取所有数据\n",
    "    data_list = glob.glob(Input_folder+'\\\\'+'*.nc')\n",
    "    \n",
    "    for i in range(len(data_list)):\n",
    "        data = data_list[i]\n",
    "        nc2tif(data, Output_folder)\n",
    "        print(data+'转tif成功')\n",
    "        \n",
    "main()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "eb91c4bc",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "myenv2",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.18"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
